//
//  HJSearchNavBar.m
//  Sneakers
//
//  Created by 胡光健 on 2017/10/20.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HJSearchNavBar.h"
@interface HJSearchNavBar ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIView *view;


@end
@implementation HJSearchNavBar

-(instancetype)init {
    if (self = [super init]) {
        self = [[NSBundle mainBundle] loadNibNamed:@"SearchNavBar" owner:nil options:nil].firstObject;
    }
    return self;
}

-(void)awakeFromNib {
    [super awakeFromNib];
    self.view.backgroundColor = [UIColor whiteColor];
    self.view.layer.cornerRadius = 3;
    self.view.layer.masksToBounds = NO;
    self.view.layer.shadowOpacity = 0.5;
    self.view.layer.shadowRadius = 1;
    self.view.layer.shadowOffset = CGSizeZero;
    self.view.layer.shadowColor = [UIColor grayColor].CGColor;
    
    self.searchText.delegate = self;
    self.layer.shadowOpacity = 0.25;
    self.layer.shadowRadius = 3;
    self.layer.shadowOffset = CGSizeZero;
    self.layer.shadowColor =HJColorRGB(0).CGColor;
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    if ([self.delegate respondsToSelector:@selector(searchBarTextReturnWithText:)]) {
        [self.delegate searchBarTextReturnWithText:textField.text];
    }
    [textField resignFirstResponder];
    return YES;
}
- (IBAction)back:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(searchBarBackBtnClicked)]) {
        [self.delegate searchBarBackBtnClicked];
    }
}

- (IBAction)search:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(searchBtnClicked)]) {
        [self.delegate searchBtnClicked];
    }
}
@end
